package com.company.hrmadmin.common.util;

/**
 * @author Song, Wei
 * Date: 2022/4/21 14:20
 */
public class RedisKeyUtil {

    /**
     * 用户对象的KEY
     */
    public static final String PREFIX_USER = "user";

    /**
     * 验证码KEY前缀
     */
    private static final String PREFIX_VERIFY = "verify";

    /**
     * 登录凭证前缀
     */
    private static final String PREFIX_TOKEN = "token";

    /**
     * 分隔符
     */
    public static final String SPLIT = ":";

    /**
     * 获取验证码KEY
     *
     * @param account 邮箱账号
     * @return Key
     */
    public static String getVerifyKey(String account) {
        return PREFIX_VERIFY + SPLIT + account;
    }

    /**
     * 获取 User 的 Key 值
     *
     * @param userId 用户ID
     * @return 用户RedisKey
     */
    public static String getUserKey(String userId) {
        return PREFIX_TOKEN + SPLIT + userId;
    }

    /**
     * 生成登录Token的 key 值
     *
     * @param token token 字符串
     * @return 登录token保存的 key 值
     */
    public static String getTokenKey(String token) {
        return PREFIX_TOKEN + SPLIT + token;
    }

}
